/**
 * Created by niefengjun on 14-12-2.
 */
var db = require('./db');
var tool = require('../tool');


function list(callback)
{
    var sql =    'select id,name,textes from new_table ';
    // console.log(sql) ;
    db.dbExecuteSql(sql, function (err, result) {
            //console.log("list---"+err,result) ;
            if(!err) {
                callback(err, result);
            }
            else
            {
                console.log("list---"+err,result) ;
                callback(err, result);
            }
        }
    );
}



function add(username, password, callback) {
    var add = 'INSERT INTO new_table (`name`,`textes`)  VALUES ('
        + tool.sqlstring(username) + ',' + tool.sqlstring(password) + ')';
    db.dbExecuteSql(add, function (err, value) {
        if (!err) {
            callback(null, 'suess');
        }
        else {
            callback(err, null);
        }
    });
}

exports.list = list;
exports.add = add;